<?

$menuDbEntry = "<?

/**
* Use \$_SESSION[\"GDate\"] if you are using custom date
* or just use the system date
*
* \$today_date = \$_SESSION[\"GDate\"];
* \$today_date = date(\"d-m-Y\");
*
*/
\$today_date		  = date(\"d-m-Y\");

\$thisSequence   = \"".$entSeqName."\";
\$jobIdTag       = \"".$menuNumber."\";

\$srcDbHdr      = \"".$srcDbHdr."\";
\$srcDbDtl      = \"".$srcDbDtl."\";
\$srcDbHdrLog   = \"LOG_".$srcDbHdr."\";
\$srcDbSequence = \"MST_SEQUENCE\";

\$UID     = unserialize(\$_SESSION[\"serUID\"]);

\$userId  = \$UID->getUID();

\$Db = new ".$dbTech.";
\$Db->init(\$_SESSION[\"ORCL\"],
           \$_SESSION[\"OPASS\"],
           \$_SESSION[\"SID\"],
           _NO_COMMENT);

if(\$Db->connect()){

	\$thisPeriode = &\$_SESSION[\"sysPeriode\"];

	/**
	* Fetch the sequence number
	* and below is the how to
	*
	* 1. we fetch the current number
	* 2. we update the current number
	* 3. if the fetched number as condition is
	*    valid then there is no interuption while
	*    updating
	*
	*/

	\$seqEditStatus = false;

	while(\$seqEditStatus == false){

  	\$CFetchers->fetchCurSequence(\$Db,
                	               \$thisSequence,
                	               \$thisPeriode,
                	               \$SourceDb->getValue(\"srcDbSequence\"),
                	               \$srcJidIndex);

  	\$CHandlers->initCurSequence(\$Db,
                	              \$thisSequence,
                	              \$srcJidIndex,
                	              \$thisPeriode,
                	              \$SourceDb->getValue(\"srcDbSequence\"),
                	              \$seqEditStatus);
  }

  /**
  * Extract the system period
  *
  */
  \$tmpDate = explode(\"-\", \$thisPeriode);
  \$wrkDate = \$tmpDate[0]. /* This period month */
             \"-\".
             \$tmpDate[1]; /* This period year */

  \$jobId  = addDigit((string) \$srcJidIndex).
            \$srcJidIndex.
            \"/\" .
            \$jobIdTag.
            \"/\" .
            \$wrkDate;

  \$hdrDate = \"TO_DATE('\".\$_POST[\"trDateEnt\"].\"' , 'dd-mm-YYYY')\";


  \$CFetchers->fetchHdrNo(\$Db,
                         \$_POST[\"trDateEnt\"],
                         \$srcDbHdr,
                         \$hdrNo);

  /**
  * Insert Log
  *
  */
  \$CHandlers->insToDbLog(\$Db,
                         \$today_date,
                         \$jobId,
                         \$userId,
                         \$_SERVER[\"REMOTE_ADDR\"],
                         _ENTRY_MODE,
                         \$srcDbHdrLog);

	\$Db->commit();

	if(\$Db->getStatus()){

	  \$Misc->usrMsg(\"Upload Complete\");
	}else{

	  \$Misc->usrDieJs(\"Upload Process Interupted\");
	}

	\$Db->dc();

	/**
	* Pending...
	* I'm not sure if this
	* reset procedure off
	* causes buggy
	*
	*	\$restore  = 0;
	* \$uprun    = 0;
	* \$dataup   = 0;
	*
	*/

	//jumpTo(2,\"../\".\$_SESSION[\"source_caller\"]);

}else{

	\$Misc->usrDieJs(_DB_CONN_ERROR);
}

?> ";

$menuDbModify = "<?

/**
* Use \$_SESSION[\"GDate\"] if you are using custom date
* or just use the system date
*
* \$today_date = \$_SESSION[\"GDate\"];
* \$today_date = date(\"d-m-Y\");
*
*/
\$today_date		  = date(\"d-m-Y\");

\$srcDbHdr    = \"".$srcDbHdr."\";
\$srcDbDtl    = \"".$srcDbDtl."\";
\$srcDbHdrLog = \"LOG_".$srcDbHdr."\";

\$UID     = unserialize(\$_SESSION[\"serUID\"]);
\$userId  = \$UID->getUID();

\$Db = new ".$dbTech.";
\$Db->init(\$_SESSION[\"ORCL\"],
           \$_SESSION[\"OPASS\"],
           \$_SESSION[\"SID\"],
           _NO_COMMENT);

if(\$Db->connect()){

	/**
	* Delete the previous entry
	*
	*/
	\$CHandlers->dbEntDelete(\$Db,
            	            \$_SESSION[\"jid\"],
            	            \$srcDbHdr);

  \$CHandlers->dbEntDelete(\$Db,
            	            \$_SESSION[\"jid\"],
            	            \$srcDbDtl);

  /**
  * We don't build up any jobId anymore since this is
  * a modify mode. Also we already have the previous
  * jobId in \$_SESSION
  *
  */
  \$jobId = \$_SESSION[\"jid\"];

  \$hdrDate = \"TO_DATE('\".\$_POST[\"trDateEnt\"].\"' , 'dd-mm-YYYY')\";

  \$CFetchers->fetchHdrNo(\$Db,
                         \$_POST[\"trDateEnt\"],
                         \$srcDbHdr,
                         \$hdrNo);

  /**
  * Insert Log
  *
  */
  \$CHandlers->insToDbLog(\$Db,
                         \$today_date,
                         \$jobId,
                         \$userId,
                         \$_SERVER[\"REMOTE_ADDR\"],
                         _ENTRY_MODE,
                         \$srcDbHdrLog);

	\$Db->commit();

	if(\$Db->getStatus() == true){

	  \$Misc->usrMsg(\"Modify Complete\");
	}else{

	  \$Misc->usrDieJs(\"Modify Process Interupted\");
	}

	\$Db->dc();

	/**
	* Pending...
	* I'm not sure if this
	* reset procedure off
	* causes buggy
	*
	*	\$restore  = 0;
	* \$uprun    = 0;
	* \$dataup   = 0;
	*
	*/
	//jumpTo(2,\"../\".\$_SESSION[\"source_caller\"]);

}else{

	\$Misc->usrDieJs(_DB_CONN_ERROR);
}

?> ";
?>